﻿using Hrm.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hrm.Services
{
    public class TeamMemberService : BaseService<TeamMenber>, ITeamMemberService
    {
        ITeamMenberStudioDbRepository _teamMenberStudioDbRepository;
        public TeamMemberService(ITeamMenberStudioDbRepository teamMenberStudioDbRepository)
            : base(teamMenberStudioDbRepository)
        {
            _teamMenberStudioDbRepository = teamMenberStudioDbRepository;
        }

        public TeamMenber FirstTeamMenber()
        {
            return _teamMenberStudioDbRepository.GetList(p => p.Type == TeamMenberTypeStruct.CorePerson).OrderBy(p => p.OrderNum).FirstOrDefault();
        }

        public List<TeamMenber> SecondToNTeamMenber()
        {
            var query = _teamMenberStudioDbRepository.GetList(p => p.Type == TeamMenberTypeStruct.CorePerson).OrderBy(p => p.OrderNum).ToList();
            if (query.Count > 1)
                query.RemoveAt(0);
            return query;
        }

        public List<TeamMenber> AllClient()
        {
            var query = _teamMenberStudioDbRepository.GetList(p => p.Type == TeamMenberTypeStruct.Client).OrderBy(p => p.OrderNum).ToList();
            return query;
        }
    }
}
